<template>
	<view class='cu-modal modal-bottom' :class='{show: show}'>
		<view class='modal'>
			<view class='head'>
				<text class='title'>管理标签</text>
				<text class='close cuIcon-close' @click='handleClose'></text>
			</view>
			<view class='form'>
				<view class='tags'>
					<view v-if="index" class='tag-item' v-for='(item,index) in tags' :key='item.id'>
						{{item.title}}
						<text class='close cuIcon-roundclosefill' @click='handleDel(index)'></text>
					</view>
				</view>
			</view>
			<view class='submit' @click='handleSubmit'>确定</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				tags: [],
				success:null
			}
		},
		created() {
			
		},
		methods: {
			handleOpen(e) {
				this.tags = JSON.parse(JSON.stringify(e.tags))
				this.success = e.success
				this.show = true;
			},
			handleClose() {
				this.show = false;
			},
			handleDel(index) {
				this.tags.splice(index,1)
			},
			handleSubmit() {
				if(this.success){
					this.success(this.tags)
				}
				this.handleClose()
			},
		}
	}
</script>

<style scoped lang="scss">
	.modal {
		width: 100%;
		position: absolute;
		left: 0;
		bottom: 0;
		background: #FFFFFF;
		padding: 0 32rpx 76rpx 32rpx;
		text-align: left;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		
		.head {
			text-align: center;
			font-weight: 500;
			font-size: 30rpx;
			color: var(--h1Color);
			padding: 32rpx 0 64rpx 0;
			position: relative;
			
			.close {
				position: absolute;
				top:  32rpx;
				right: 0;
			}
		}
		
		.form {
			.tags {
				display: flex;
				flex-wrap: wrap;
				gap: 16rpx;
				
				.tag-item {
					height: 72rpx;
					background: var(--tagBg);
					border-radius: 8rpx;
					padding: 0 40rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 26rpx;
					color: var(--h1Color);
					position: relative;
					
					.close {
						position: absolute;
						top: -16rpx;
						right: -16rpx;
						font-size: 38rpx;
					}
				}
			}
		}
		
		.submit {
			margin-top: 72rpx;
			width: 100%;
			height: 96rpx;
			background: var(--primaryGradBg);
			border-radius: 48rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: 600;
			font-size: 32rpx;
			color: var(--btnColor);
		}
	}
</style>